/**
 * @param {string} s
 * @return {string}
 */
var decodeString = function (s) {
    const stack = []
    let str = ''
    let n = ''
    for (let i = 0; i < s.length; i++) {
        // 是字母
        if (s[i] >= 'a' && s[i] <= 'z') {
            str += s[i]
        } else {
            stack.push(str)
            str = ''
            if (s[i] >= '0' && s[i] <= '9') { // 是数字
                n += s[i]
            } else if (s[i] === '[') {
                stack.push(parseInt(n))
                stack.push('[')
                n = ''
            } else {
                let temps = ''
                let tempRes = ''
                while(stack.length > 0 && stack[stack.length - 1] !== '[') {
                    tempS += stack.pop()
                }
                stack.pop() // 去掉左括号
                let count = stack.pop() // 拿到重复数字
                for(let j = 1; j <= count; j++) {
                    tempRes += temps
                }
                stack.push(temps)
            }
        }
    }
    console.log(stack);
};
// "3[a]2[bc]"  "3[a2[c]]"  abc3[cd]xyz